﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Xml;
using Autodesk.Revit.UI;
using HYElectricCommon;
using HYFamilyLibDataManager;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;

namespace YArchitech.Revit.MEP.Calculator
{
	public class LoadCalculationHelper
	{
		public static void ExportExcel(LoadCalculationForm form)
		{
			DataGridView dgvLoadCal = form.dgvLoadCal;
			DataGridView dgvCalResult = form.dgvCalResult;
			DataGridView dgvCalCCResult = form.dgvCalCCResult;
			int count = dgvLoadCal.Rows.Count;
			int count2 = dgvLoadCal.Columns.Count;
			if (count > 65536)
			{
				MessageBox.Show("数据记录数太多(最多不能超过65536条)，不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			if (count2 > 255)
			{
				MessageBox.Show("数据记录行数太多，不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
            try
            {
            }
            //{
            //    Microsoft.Office.Interop.Excel.Application application = (Microsoft.Office.Interop.Excel.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
            //    Microsoft.Office.Interop.Excel.Workbook workbook = application.Workbooks.Add(Missing.Value);
            //    if (LoadCalculationHelper.<>o__0.<>p__0 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__0 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Worksheet), typeof(LoadCalculationHelper)));
            //    }
            //    Microsoft.Office.Interop.Excel.Worksheet worksheet = LoadCalculationHelper.<>o__0.<>p__0.Target(LoadCalculationHelper.<>o__0.<>p__0, workbook.ActiveSheet);
            //    application.Visible = true;
            //    Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("C1", "M4");
            //    range.Merge(Type.Missing);
            //    range.set_Value(Type.Missing, "负荷计算");
            //    range.Font.Size = 40;
            //    range.Font.Color = System.Drawing.Color.Red;
            //    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
            //    int num = 5;
            //    num = LoadCalculationHelper.DrawingLoadCalInfo(dgvLoadCal, application, worksheet, num);
            //    num += 3;
            //    if (LoadCalculationHelper.<>o__0.<>p__3 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__3 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target = LoadCalculationHelper.<>o__0.<>p__3.Target;
            //    CallSite <>p__ = LoadCalculationHelper.<>o__0.<>p__3;
            //    if (LoadCalculationHelper.<>o__0.<>p__2 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__2 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target2 = LoadCalculationHelper.<>o__0.<>p__2.Target;
            //    CallSite <>p__2 = LoadCalculationHelper.<>o__0.<>p__2;
            //    if (LoadCalculationHelper.<>o__0.<>p__1 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__1 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    Microsoft.Office.Interop.Excel.Range range2 = target(<>p__, target2(<>p__2, LoadCalculationHelper.<>o__0.<>p__1.Target(LoadCalculationHelper.<>o__0.<>p__1, worksheet), worksheet.Cells[num - 1, 3], worksheet.Cells[num - 1, dgvCalResult.Columns.Count + 2]));
            //    range2.Merge(Type.Missing);
            //    range2.set_Value(Type.Missing, "计算结果(不计入补偿容量)：");
            //    range2.Font.Color = System.Drawing.Color.Black;
            //    range2.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //    num = LoadCalculationHelper.DrawingLoadCalInfo(dgvCalResult, application, worksheet, num);
            //    num += 3;
            //    if (LoadCalculationHelper.<>o__0.<>p__6 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__6 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target3 = LoadCalculationHelper.<>o__0.<>p__6.Target;
            //    CallSite <>p__3 = LoadCalculationHelper.<>o__0.<>p__6;
            //    if (LoadCalculationHelper.<>o__0.<>p__5 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__5 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target4 = LoadCalculationHelper.<>o__0.<>p__5.Target;
            //    CallSite <>p__4 = LoadCalculationHelper.<>o__0.<>p__5;
            //    if (LoadCalculationHelper.<>o__0.<>p__4 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__4 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    Microsoft.Office.Interop.Excel.Range range3 = target3(<>p__3, target4(<>p__4, LoadCalculationHelper.<>o__0.<>p__4.Target(LoadCalculationHelper.<>o__0.<>p__4, worksheet), worksheet.Cells[num - 1, 3], worksheet.Cells[num - 1, dgvCalCCResult.Columns.Count + 2]));
            //    range3.Merge(Type.Missing);
            //    range3.set_Value(Type.Missing, "计算结果(计入补偿容量)：");
            //    range3.Font.Color = System.Drawing.Color.Black;
            //    range3.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //    num = LoadCalculationHelper.DrawingLoadCalInfo(dgvCalCCResult, application, worksheet, num);
            //    if (LoadCalculationHelper.<>o__0.<>p__9 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__9 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target5 = LoadCalculationHelper.<>o__0.<>p__9.Target;
            //    CallSite <>p__5 = LoadCalculationHelper.<>o__0.<>p__9;
            //    if (LoadCalculationHelper.<>o__0.<>p__8 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__8 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target6 = LoadCalculationHelper.<>o__0.<>p__8.Target;
            //    CallSite <>p__6 = LoadCalculationHelper.<>o__0.<>p__8;
            //    if (LoadCalculationHelper.<>o__0.<>p__7 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__7 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target5(<>p__5, target6(<>p__6, LoadCalculationHelper.<>o__0.<>p__7.Target(LoadCalculationHelper.<>o__0.<>p__7, worksheet), worksheet.Cells[num + 2, 3], worksheet.Cells[num + 2, 3])).set_Value(Type.Missing, "变压器选型：");
            //    if (LoadCalculationHelper.<>o__0.<>p__12 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__12 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target7 = LoadCalculationHelper.<>o__0.<>p__12.Target;
            //    CallSite <>p__7 = LoadCalculationHelper.<>o__0.<>p__12;
            //    if (LoadCalculationHelper.<>o__0.<>p__11 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__11 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target8 = LoadCalculationHelper.<>o__0.<>p__11.Target;
            //    CallSite <>p__8 = LoadCalculationHelper.<>o__0.<>p__11;
            //    if (LoadCalculationHelper.<>o__0.<>p__10 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__10 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target7(<>p__7, target8(<>p__8, LoadCalculationHelper.<>o__0.<>p__10.Target(LoadCalculationHelper.<>o__0.<>p__10, worksheet), worksheet.Cells[num + 3, 3], worksheet.Cells[num + 3, 3])).set_Value(Type.Missing, "负荷率：");
            //    if (LoadCalculationHelper.<>o__0.<>p__15 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__15 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target9 = LoadCalculationHelper.<>o__0.<>p__15.Target;
            //    CallSite <>p__9 = LoadCalculationHelper.<>o__0.<>p__15;
            //    if (LoadCalculationHelper.<>o__0.<>p__14 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__14 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target10 = LoadCalculationHelper.<>o__0.<>p__14.Target;
            //    CallSite <>p__10 = LoadCalculationHelper.<>o__0.<>p__14;
            //    if (LoadCalculationHelper.<>o__0.<>p__13 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__13 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target9(<>p__9, target10(<>p__10, LoadCalculationHelper.<>o__0.<>p__13.Target(LoadCalculationHelper.<>o__0.<>p__13, worksheet), worksheet.Cells[num + 3, 4], worksheet.Cells[num + 3, 4])).set_Value(Type.Missing, form.tbLoadRate.Text);
            //    if (LoadCalculationHelper.<>o__0.<>p__18 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__18 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target11 = LoadCalculationHelper.<>o__0.<>p__18.Target;
            //    CallSite <>p__11 = LoadCalculationHelper.<>o__0.<>p__18;
            //    if (LoadCalculationHelper.<>o__0.<>p__17 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__17 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target12 = LoadCalculationHelper.<>o__0.<>p__17.Target;
            //    CallSite <>p__12 = LoadCalculationHelper.<>o__0.<>p__17;
            //    if (LoadCalculationHelper.<>o__0.<>p__16 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__16 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target11(<>p__11, target12(<>p__12, LoadCalculationHelper.<>o__0.<>p__16.Target(LoadCalculationHelper.<>o__0.<>p__16, worksheet), worksheet.Cells[num + 3, 5], worksheet.Cells[num + 3, 5])).set_Value(Type.Missing, "变压器名称：");
            //    if (LoadCalculationHelper.<>o__0.<>p__21 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__21 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target13 = LoadCalculationHelper.<>o__0.<>p__21.Target;
            //    CallSite <>p__13 = LoadCalculationHelper.<>o__0.<>p__21;
            //    if (LoadCalculationHelper.<>o__0.<>p__20 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__20 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target14 = LoadCalculationHelper.<>o__0.<>p__20.Target;
            //    CallSite <>p__14 = LoadCalculationHelper.<>o__0.<>p__20;
            //    if (LoadCalculationHelper.<>o__0.<>p__19 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__19 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target13(<>p__13, target14(<>p__14, LoadCalculationHelper.<>o__0.<>p__19.Target(LoadCalculationHelper.<>o__0.<>p__19, worksheet), worksheet.Cells[num + 3, 6], worksheet.Cells[num + 3, 6])).set_Value(Type.Missing, form.cmbTransformName.SelectedItem);
            //    if (LoadCalculationHelper.<>o__0.<>p__24 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__24 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target15 = LoadCalculationHelper.<>o__0.<>p__24.Target;
            //    CallSite <>p__15 = LoadCalculationHelper.<>o__0.<>p__24;
            //    if (LoadCalculationHelper.<>o__0.<>p__23 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__23 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target16 = LoadCalculationHelper.<>o__0.<>p__23.Target;
            //    CallSite <>p__16 = LoadCalculationHelper.<>o__0.<>p__23;
            //    if (LoadCalculationHelper.<>o__0.<>p__22 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__22 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target15(<>p__15, target16(<>p__16, LoadCalculationHelper.<>o__0.<>p__22.Target(LoadCalculationHelper.<>o__0.<>p__22, worksheet), worksheet.Cells[num + 3, 7], worksheet.Cells[num + 3, 7])).set_Value(Type.Missing, "台数：");
            //    if (LoadCalculationHelper.<>o__0.<>p__27 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__27 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target17 = LoadCalculationHelper.<>o__0.<>p__27.Target;
            //    CallSite <>p__17 = LoadCalculationHelper.<>o__0.<>p__27;
            //    if (LoadCalculationHelper.<>o__0.<>p__26 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__26 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target18 = LoadCalculationHelper.<>o__0.<>p__26.Target;
            //    CallSite <>p__18 = LoadCalculationHelper.<>o__0.<>p__26;
            //    if (LoadCalculationHelper.<>o__0.<>p__25 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__25 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target17(<>p__17, target18(<>p__18, LoadCalculationHelper.<>o__0.<>p__25.Target(LoadCalculationHelper.<>o__0.<>p__25, worksheet), worksheet.Cells[num + 3, 8], worksheet.Cells[num + 3, 8])).set_Value(Type.Missing, form.nudCount.Value);
            //    if (LoadCalculationHelper.<>o__0.<>p__30 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__30 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target19 = LoadCalculationHelper.<>o__0.<>p__30.Target;
            //    CallSite <>p__19 = LoadCalculationHelper.<>o__0.<>p__30;
            //    if (LoadCalculationHelper.<>o__0.<>p__29 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__29 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target20 = LoadCalculationHelper.<>o__0.<>p__29.Target;
            //    CallSite <>p__20 = LoadCalculationHelper.<>o__0.<>p__29;
            //    if (LoadCalculationHelper.<>o__0.<>p__28 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__28 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target19(<>p__19, target20(<>p__20, LoadCalculationHelper.<>o__0.<>p__28.Target(LoadCalculationHelper.<>o__0.<>p__28, worksheet), worksheet.Cells[num + 3, 9], worksheet.Cells[num + 3, 9])).set_Value(Type.Missing, "变压器规格：");
            //    if (LoadCalculationHelper.<>o__0.<>p__33 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__33 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target21 = LoadCalculationHelper.<>o__0.<>p__33.Target;
            //    CallSite <>p__21 = LoadCalculationHelper.<>o__0.<>p__33;
            //    if (LoadCalculationHelper.<>o__0.<>p__32 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__32 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target22 = LoadCalculationHelper.<>o__0.<>p__32.Target;
            //    CallSite <>p__22 = LoadCalculationHelper.<>o__0.<>p__32;
            //    if (LoadCalculationHelper.<>o__0.<>p__31 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__31 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target21(<>p__21, target22(<>p__22, LoadCalculationHelper.<>o__0.<>p__31.Target(LoadCalculationHelper.<>o__0.<>p__31, worksheet), worksheet.Cells[num + 3, 10], worksheet.Cells[num + 3, 10])).set_Value(Type.Missing, form.cmbTransformSpec.SelectedItem);
            //    if (LoadCalculationHelper.<>o__0.<>p__36 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__36 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target23 = LoadCalculationHelper.<>o__0.<>p__36.Target;
            //    CallSite <>p__23 = LoadCalculationHelper.<>o__0.<>p__36;
            //    if (LoadCalculationHelper.<>o__0.<>p__35 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__35 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target24 = LoadCalculationHelper.<>o__0.<>p__35.Target;
            //    CallSite <>p__24 = LoadCalculationHelper.<>o__0.<>p__35;
            //    if (LoadCalculationHelper.<>o__0.<>p__34 == null)
            //    {
            //        LoadCalculationHelper.<>o__0.<>p__34 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    Microsoft.Office.Interop.Excel.Range range4 = target23(<>p__23, target24(<>p__24, LoadCalculationHelper.<>o__0.<>p__34.Target(LoadCalculationHelper.<>o__0.<>p__34, worksheet), worksheet.Cells[num + 3, 3], worksheet.Cells[num + 3, 10]));
            //    range4.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //    range4.Borders.Color = System.Drawing.Color.Red;
            //    range4.EntireColumn.AutoFit();
            //    range4.Borders.LineStyle = 1;
            //}
            catch
            {
            }
		}

		private static int DrawingLoadCalInfo(DataGridView dgvCal, Microsoft.Office.Interop.Excel.Application objExcel, Microsoft.Office.Interop.Excel.Worksheet objsheet, int rowindex)
		{
            //if (LoadCalculationHelper.<>o__1.<>p__2 == null)
            //{
            //    LoadCalculationHelper.<>o__1.<>p__2 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(LoadCalculationHelper)));
            //}
            //Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target = LoadCalculationHelper.<>o__1.<>p__2.Target;
            //CallSite <>p__ = LoadCalculationHelper.<>o__1.<>p__2;
            //if (LoadCalculationHelper.<>o__1.<>p__1 == null)
            //{
            //    LoadCalculationHelper.<>o__1.<>p__1 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //    }));
            //}
            //Func<CallSite, object, object, object, object> target2 = LoadCalculationHelper.<>o__1.<>p__1.Target;
            //CallSite <>p__2 = LoadCalculationHelper.<>o__1.<>p__1;
            //if (LoadCalculationHelper.<>o__1.<>p__0 == null)
            //{
            //    LoadCalculationHelper.<>o__1.<>p__0 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(LoadCalculationHelper), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //Microsoft.Office.Interop.Excel.Range range = target(<>p__, target2(<>p__2, LoadCalculationHelper.<>o__1.<>p__0.Target(LoadCalculationHelper.<>o__1.<>p__0, objsheet), objsheet.Cells[rowindex, 3], objsheet.Cells[rowindex + dgvCal.Rows.Count, dgvCal.Columns.Count + 2]));
            //range.Borders.Color = System.Drawing.Color.Red;
            //range.EntireColumn.AutoFit();
            //range.Borders.LineStyle = 1;
            //int num = 3;
            //for (int i = 0; i < dgvCal.ColumnCount; i++)
            //{
            //    if (dgvCal.Columns[i].Visible)
            //    {
            //        objExcel.Cells[rowindex, num] = dgvCal.Columns[i].HeaderText.Trim();
            //        num++;
            //    }
            //}
            //for (int j = 0; j <= dgvCal.RowCount - 1; j++)
            //{
            //    num = 3;
            //    for (int k = 0; k < dgvCal.Columns.Count; k++)
            //    {
            //        if (dgvCal.Columns[k].Visible)
            //        {
            //            try
            //            {
            //                if (dgvCal.Rows[j].Cells[k].Value == null)
            //                {
            //                    objExcel.Cells[rowindex + 1, num] = "";
            //                }
            //                else
            //                {
            //                    objExcel.Cells[rowindex + 1, num] = dgvCal.Rows[j].Cells[k].Value.ToString().Trim();
            //                }
            //                num++;
            //            }
            //            catch (Exception)
            //            {
            //            }
            //        }
            //    }
            //    rowindex++;
            //}
			return rowindex;
		}

		public static void ExportWord(LoadCalculationForm form)
		{
			object value = Missing.Value;
			Microsoft.Office.Interop.Word.Application application = (Microsoft.Office.Interop.Word.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("000209FF-0000-0000-C000-000000000046")));
			Document document = application.Documents.Add(ref value, ref value, ref value, ref value);
			application.Visible = true;
			Paragraph paragraph = document.Paragraphs.Add(ref value);
			Microsoft.Office.Interop.Word.Range range = paragraph.Range;
			range.Text = "负荷计算书";
			range.Font.Size = 30f;
			range.Font.Bold = 1;
			paragraph.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
			paragraph.Format.SpaceAfter = 24f;
			range.InsertParagraphAfter();
			Paragraph paragraph2 = document.Paragraphs.Add(ref value);
			Microsoft.Office.Interop.Word.Range range2 = paragraph2.Range;
			range2.Text = "计算依据";
			range2.Font.Size = 20f;
			range2.Font.Bold = 1;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range2.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range3 = paragraph2.Range;
			range3.Text = "《工业与民用配电设计手册》第三版";
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 2f;
			range3.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range4 = paragraph2.Range;
			range4.Text = "《现代建筑电气设计实用指南》";
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range4.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range5 = paragraph2.Range;
			range5.Text = "计算结果";
			range5.Font.Size = 20f;
			range5.Font.Bold = 1;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 24f;
			range5.InsertParagraphAfter();
			try
			{
				DataGridView dgvLoadCal = form.dgvLoadCal;
				Microsoft.Office.Interop.Word.Range range6 = document.Paragraphs.Add(ref value).Range;
				Table table = document.Tables.Add(range6, dgvLoadCal.Rows.Count - 1, dgvLoadCal.Columns.Count, ref value, ref value);
				table.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
				table.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
				LoadCalculationHelper.SetTable(table, dgvLoadCal);
				object obj = WdUnits.wdLine;
				int num = 20;
				Selection selection = application.Selection;
				object obj2 = num;
				object obj3 = Missing.Value;
				selection.MoveDown(ref obj, ref obj2, ref obj3);
				obj = WdUnits.wdLine;
				application.Selection.TypeParagraph();
				Microsoft.Office.Interop.Word.Range range7 = paragraph2.Range;
				range7.Text = "计算结果(不计入补偿容量)：";
				range7.Font.Size = 10f;
				paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
				paragraph2.Format.SpaceAfter = 10f;
				range7.InsertParagraphAfter();
				DataGridView dgvCalResult = form.dgvCalResult;
				Microsoft.Office.Interop.Word.Range range8 = document.Paragraphs.Add(ref value).Range;
				Table table2 = document.Tables.Add(range8, dgvCalResult.Rows.Count + 1, dgvCalResult.ColumnCount, ref value, ref value);
				table2.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
				table2.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
				LoadCalculationHelper.SetTable(table2, dgvCalResult);
				object obj4 = WdUnits.wdLine;
				Selection selection2 = application.Selection;
				obj3 = num;
				obj2 = Missing.Value;
				selection2.MoveDown(ref obj4, ref obj3, ref obj2);
				obj4 = WdUnits.wdLine;
				application.Selection.TypeParagraph();
				Microsoft.Office.Interop.Word.Range range9 = paragraph2.Range;
				range9.Text = "计算结果(计入补偿容量)：";
				range9.Font.Size = 10f;
				paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
				paragraph2.Format.SpaceAfter = 10f;
				range9.InsertParagraphAfter();
				DataGridView dgvCalCCResult = form.dgvCalCCResult;
				Microsoft.Office.Interop.Word.Range range10 = document.Paragraphs.Add(ref value).Range;
				Table table3 = document.Tables.Add(range10, dgvCalCCResult.Rows.Count + 1, dgvCalCCResult.ColumnCount, ref value, ref value);
				table3.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
				table3.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
				LoadCalculationHelper.SetTable(table3, dgvCalCCResult);
				Microsoft.Office.Interop.Word.Range range11 = paragraph2.Range;
				range11.Text = "变压器选型：";
				range11.Font.Size = 10f;
				paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
				paragraph2.Format.SpaceAfter = 10f;
				range11.InsertParagraphAfter();
				object obj5 = WdUnits.wdLine;
				Selection selection3 = application.Selection;
				obj2 = num;
				obj3 = Missing.Value;
				selection3.MoveDown(ref obj5, ref obj2, ref obj3);
				application.Selection.TypeParagraph();
				Microsoft.Office.Interop.Word.Range range12 = document.Paragraphs.Add(ref value).Range;
				Table table4 = document.Tables.Add(range12, 1, 8, ref value, ref value);
				table4.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
				table4.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
				table4.Cell(1, 1).Range.Text = "负荷率：";
				table4.Cell(1, 2).Range.Text = form.tbLoadRate.Text;
				table4.Cell(1, 3).Range.Text = "变压器名称：";
				table4.Cell(1, 4).Range.Text = form.cmbTransformName.SelectedItem.ToString();
				table4.Cell(1, 5).Range.Text = "台数：";
				table4.Cell(1, 6).Range.Text = form.nudCount.Value.ToString();
				table4.Cell(1, 7).Range.Text = "变压器规格：";
				table4.Cell(1, 8).Range.Text = form.cmbTransformSpec.SelectedItem.ToString();
			}
			catch
			{
			}
		}

		public static void SetTable(Table table, DataGridView srcDgv)
		{
			int count = srcDgv.Rows.Count;
			int count2 = srcDgv.Columns.Count;
			table.Range.Font.Size = 10f;
			table.Range.Font.Bold = 0;
			for (int i = 0; i < count2; i++)
			{
				table.Cell(1, i + 1).Range.Text = srcDgv.Columns[i].HeaderText;
			}
			for (int j = 0; j < count; j++)
			{
				for (int k = 0; k < count2; k++)
				{
					object value = srcDgv.Rows[j].Cells[k].Value;
					if (count >= 3 && count - 3 == j)
					{
						break;
					}
					int row;
					if (count >= 3 && count - 1 == j)
					{
						row = j + 1;
					}
					else
					{
						row = j + 2;
					}
					if (value == null)
					{
						table.Cell(row, k + 1).Range.Text = "";
					}
					else
					{
						table.Cell(row, k + 1).Range.Text = value.ToString();
					}
				}
			}
		}

		public static List<TransformerData> GetTransformerData(ExternalCommandData cmdData)
		{
			List<TransformerData> list = new List<TransformerData>();
			try
			{
				foreach (DbFamily dbFamily in FamilyLibDatabase.GetSqliteDB(SubjectType.Electric, cmdData.Application.Application.VersionNumber).CategoryTable["变压器"].GetAllFamilies(false, CheckType.All))
				{
					TransformerData transformerData = new TransformerData();
					transformerData.Name = dbFamily.Name;
					Dictionary<string, double> dictionary = new Dictionary<string, double>();
                    System.Data.DataTable dataTable = dbFamily.Database.TypeTable.DataTable(dbFamily);
					for (int i = 0; i < dataTable.Rows.Count; i++)
					{
						if (!dictionary.ContainsKey(dataTable.Rows[i]["规格名"].ToString()))
						{
							dictionary.Add(dataTable.Rows[i]["规格名"].ToString(), Convert.ToDouble(dataTable.Rows[i]["额定容量"]));
						}
					}
					transformerData.Specs = dictionary;
					list.Add(transformerData);
				}
			}
			catch
			{
			}
			return list;
		}

		public static List<TransformerData> GetTransformerData()
		{
			string filename = AssistFunc.GetAppRootPath() + "\\Data\\ElectricalData\\TransformerConfig.xml";
			List<TransformerData> list = new List<TransformerData>();
			XmlDocument xmlDocument = new XmlDocument();
			xmlDocument.Load(filename);
			foreach (object obj in xmlDocument.SelectNodes("TransformerSet/Transformer"))
			{
				XmlNode xmlNode = (XmlNode)obj;
				TransformerData transformerData = new TransformerData();
				transformerData.Name = xmlNode.Attributes["Name"].Value;
				Dictionary<string, double> dictionary = new Dictionary<string, double>();
				foreach (object obj2 in xmlNode.ChildNodes)
				{
					XmlNode xmlNode2 = (XmlNode)obj2;
					dictionary.Add(xmlNode2.Attributes["Name"].Value, Convert.ToDouble(xmlNode2.Attributes["RatedCapacity"].Value));
				}
				transformerData.Specs = dictionary;
				list.Add(transformerData);
			}
			return list;
		}

		public class Cal
		{
			public static string ReservedDecimal(double value)
			{
				return value.ToString("0.00");
			}

			public static double CalActivePower(double power, double needFactor)
			{
				return power * needFactor;
			}

			public static double CalRectivePower(double activePower, double powerFactor)
			{
				return activePower * Math.Tan(Math.Acos(powerFactor));
			}

			public static double GetApparentPower(double activePower, double reactivePower)
			{
				return Math.Sqrt(Math.Pow(activePower, 2.0) + Math.Pow(reactivePower, 2.0));
			}

			public static double CalElectricCurrent(double apparentPower)
			{
				return apparentPower * 1000.0 / 220.0;
			}

			public static double CalElectricCurrent3(double apparentPower)
			{
				return apparentPower * 1000.0 / (Math.Sqrt(3.0) * 380.0);
			}

			public static double CalTotolPowerFactor(double reactivePower, double activePower)
			{
				return Math.Cos(Math.Atan(reactivePower / activePower));
			}

			public static double CalCC(double compation, double activePower, double compasationBefore, double compasationAfeter)
			{
				return compation * activePower * (compasationBefore - compasationAfeter);
			}

			public static double CalculatComFator(double activePower, double reActivePower, double ActiveLoadFactor, double ReactiveLoadFactor)
			{
				double num = Math.Pow(ReactiveLoadFactor * reActivePower / (activePower * ActiveLoadFactor), 2.0);
				return Math.Sqrt(1.0 / (1.0 + num));
			}

			public static double CosTransformTan(double cos)
			{
				return Math.Sqrt(1.0 - Math.Pow(cos, 2.0)) / cos;
			}
		}
	}
}
